using System;
using System.Runtime.Serialization;
using ProtoBuf;

namespace Common
{
    [ProtoContract]
    [DataContract]
    public class PointInfo
    {
        [ProtoMember(1)]
        [DataMember]
        public TagInfo TagInfo;

        [ProtoMember(2)]
        [DataMember]
        public float[] Descriptor;

        [ProtoMember(3)]
        [DataMember]
        public int DescriptorLength;

        [ProtoMember(4)]
        [DataMember]
        public int Sign;

        [ProtoMember(5)]
        [DataMember]
        public DateTime? LastMatched;

        public PointInfo() { }

        public PointInfo(TagInfo tagInfo, float[] descriptor, int sign)
        {
            TagInfo = tagInfo;
            Descriptor = descriptor;
            DescriptorLength = descriptor.Length;
            Sign = sign;
        }

        public void SetDescriptorLength(int size)
        {
            DescriptorLength = size;
            Descriptor = new float[size];
        }

        public bool DescriptorEqual(float[] otherDescriptor)
        {
            if (DescriptorLength != otherDescriptor.Length)
                return false;

            for (int i = 0; i < DescriptorLength; i++)
                if (Descriptor[i] != otherDescriptor[i])
                    return false;

            return true;
        }
    }
}